<template>
    <div>
        <r-search :searchForm="searchForm" :searchHandle="searchHandle" :searchData="searchData" />
        <r-table :isIndex="true" :isPagination="true" :tableData="tableData" :height="350" :tableCols="tableCols" :tablePage="tablePage" @refresh="init()"></r-table>
        <r-form :formRules="formRules" :formHandle="formHandle" :formData="formData" :formCols="formCols" ref="elForm" labelWidth="200px" dialogWidth="1000px" :isHandle="true" />
    </div>
</template>
<script>
export default {
    data() {
        return {
            searchData: {
                errOrder: '',
                errType: '',
                handleResult: ''
            },
            searchForm: [
                {
                    type: 'input',
                    prop: 'errOrder',
                    placeholder: '报障单号',
                    width: 150
                },
                {
                    type: 'select',
                    prop: 'errType',
                    placeholder: '报障类型',
                    width: 150,
                    options: [
                        {
                            label: '系统报障',
                            value: '1'
                        },
                        {
                            label: '人工报障',
                            value: '2',
                        },
                    ]
                },
                {
                    type: 'select',
                    prop: 'state',
                    placeholder: '处理结果',
                    width: 150,
                    options: [
                        {
                            label: '待处理',
                            value: '1'
                        },
                        {
                            label: '已处理',
                            value: '2',
                        },
                    ]
                },
            ],
            searchHandle: [
                {
                    label: '搜索',
                    type: 'success',
                    icon: 'el-icon-search',
                    handle: e => this.elFormSubmit()
                },
                {
                    label: '重置',
                    icon: 'el-icon-refresh-right',
                    handle: e => this.searchFromReset()
                }
            ],
            tableData: [
            ],
            tableCols: [
                {
                    label: '报障单号',
                    prop: 'id',
                    // theme: e => e.status ? 'primary' : 'danger', type: "tag",
                },

                {
                    label: '报障人',
                    prop: 'nickName'
                },
                {
                    label: '联系方式',
                    prop: 'phone'
                },
                {
                    label: '设备编号',
                    prop: 'equipmentNo'
                },
                {
                    label: '运维人员',
                    prop: 'name'
                },
                {
                    label: '报障时间',
                    prop: 'createdTime'
                },
                {
                    label: '处理结果',
                    prop: 'state',
                    formatter:e=>e.state==1?'待处理':e.state==2?'已处理':''
                },
                {
                    label: '处理时间',
                    prop: 'repairTime'
                },
                {
                    label: '操作',
                    type: "button",
                    btnList: [
                        {
                            label: '查看',
                            type: 'primary',
                            // isShow: e => e.orderId == '123' ? true : false,
                            handle: (row) => this.$router.push({path:'staff-errorDetail',query:{id:row.id}})
                        },
                    ]
                }

            ],
            tablePage: { limit: 10, page: 1, total: 0 },
        };
    },
    components: {},
    computed: {},
    mounted() {
        this.init()
    },
    methods: {
        async init() {
            let param = { ...this.searchData, ...this.tablePage,optorId:this.$route.query.id }
            let res = await this.api.errlist(param)
            if (res) {
                this.tableData = res.data.list
                this.tablePage.total = res.data.total
            }
        },
        elFormSubmit(e) {
            //查询
            console.log(e)
        },
        elFormDetail(row) {
            Object.keys(this.formData).forEach(key => {
                this.formData[key] = row[key]
            })
            this.formData.id = row.id;
            this.formData.cardId = row.cardId
            // if (this.formCols[1].label == '登录密码') {
            //     this.formCols.splice(1, 1)
            // }

            this.elFormVisible()
        },
    }
};
</script>
<style scoped lang='scss'>
.el-icon-search {
  margin-right: 10px;
}
.Tip {
  margin-left: 20px;
}
</style>
